package com.sdkx.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sdkx.app.R;

import java.util.List;


public class MainMenuAdapter extends BaseAdapter {
    private Context context;
    private String[] list;

    public MainMenuAdapter(Context context,String[] list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.length;
    }

    @Override
    public Object getItem(int i) {
        return list[i];
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder holder;
        if (convertView == null) {
            convertView =  View.inflate(context, R.layout.grid_item, null);
            holder = new ViewHolder();
            holder.text = (TextView) convertView.findViewById(R.id.textView);
            convertView.setTag(holder);
            convertView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,60));
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.text.setText(list[position]);

        return convertView;
    }
    static class ViewHolder {
        TextView text;
    }

}
